package demo1107.demo01;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author JYH
 * @version 1.0
 * @date 2022/11/7 9:33
 */
public class Test02 {
    public static void main(String[] args) {

        //日期时间转化为字符串
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);

        String format = dtf.format(now);
        System.out.println(format);
        //字符串转化为日期

        LocalDateTime parse = LocalDateTime.parse("2022/11/07 15:45:01", dtf);
        System.out.println(parse);

    }
}
